# 3.13 Fan Module ## 3.13.1 Overview The motor adopts HR1124S motor control chip that is a single channel H-bridge driver chip used in DC motors. The H-bridge drive uses PMOS and NMOS power tubes with low on-resistance, ensuring lower power loss and longer safe working time. In addition, its standby and static working current are both low, so it is commonly used in toys. ## 3.13.2 Schematic Diagram ![t108](./media/t108.png) **Motor control logic table:** | IO18 | IO17 | motor state | | :--: | :--: | :-------------------: | | HIGH | LOW | forward rotate | | LOW | HIGH | reverse rotate | | HIGH | HIGH | stop (a gradual stop) | | LOW | LOW | brake (a brake stop) | ## 3.13.3 Code Blocks Blocks in ![](./media/codingBox.png): 1. ![t109](./media/t109.png) is a block included in coding box library. It controls the rotation of the motor in the coding box. **Motor control logic table for the blocks:** | motor state | value (speed) | | :------------: | :-----------: | | forward rotate | 1~100 | | reverse rotate | -1~-100 | | stop rotating | 0 | ## 3.13.4 Test Code You can manually build blocks, or directly open the code file we provide: `3-13-Fan.ubp`. If you have any questions about how to open code files or upload code, please back to `1.9 Upload Code`. **Build code blocks:** 1. In ![](./media/control.png), drag ![](./media/t1.png) and ![](./media/t2.png) to the script area, and stack them together. ![t34](./media/t34.png) 2. In ![](./media/codingBox.png), drag ![t109](./media/t109.png) and put it into![](./media/t2.png). ![t110](./media/t110.png) 3. In ![](./media/control.png), drag ![t4](./media/t4.png) block and set delay to `2000`. And put it under ![t109](./media/t109.png). ![t111](./media/t111.png) 4. Duplicate all ![t109](./media/t109.png) but modify power to `-50`. 5. Duplicate all ![t109](./media/t109.png) again but modify power to `0`. **Complete code:** ![t112](./media/t112.png) ## 3.13.5 Test Result Connect the coding box to the MicroBlocks via USB or Bluetooth, and click ![t59](./media/t59.png) to upload the code to the coding box. You will see the fan forward rotates for 2s and then reverses for another 2s. Then it stops rotating for 2 seconds. These actions repeat.